<style>
    .xxpayPopupDiv .layui-form-label {
        width:120px !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 80% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <div class="layui-tab-content">
                <form class="layui-form center">
                    <div class="layui-form-item">
                        <label class="layui-form-label">选择用户类型</label>
                        <div class="layui-input-inline">
                            <select name="infoType"><option value="1">代理商</option><option value="2">商户</option></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">系统用户ID</label>
                        <div class="layui-input-inline">
                            <input type="text" name="infoId" id="infoId" placeholder="系统用户ID" required lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付渠道接口类型</label>
                        <div class="layui-input-inline" >
                            <select name="ifTypeCode" id="ifTypeCode"></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">渠道商户号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="channelMchId" id="channelMchId" placeholder="渠道商户号" required lay-verify="required"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="remark" id="remark" placeholder="备注" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-hide xxpayYesBtn" lay-submit="" lay-filter="add">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','table','util','admin'],function(){
        var form = layui.form
        , $ = layui.$
        , admin = layui.admin
        , layer = layui.layer 
        , element = layui.element
        , table = layui.table;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

        form.render();

        // 加载支接口类型
        admin.req({
            type: 'post',
            url: layui.setter.baseUrl + '/config/common/pay_interface_type_all',
            async: false,
            error: function(err){
                layer.alert(err);
            },
            success: function(res){
                if(res.code == 0){
                    var ifTypeList = res.data;
                    //遍历赋值
                    $.each(ifTypeList, function(){
                        $("#ifTypeCode").append('<option value= '+this.ifTypeCode+'>['+this.ifTypeCode+']'+this.ifTypeName+'</option>');
                    });
                    form.render('select');
                }
            }
        });



        form.on('submit(add)', function(data){

            if(!data.field.ifTypeCode){
                return layer.alert('请选择接口类型！');
            }

            admin.req({
                type: 'post',
                url: layui.setter.baseUrl + '/config/division/mch/add', //模拟接口
                data: data.field,
                error: function(err){
                    layer.alert(err.msg,{title:"请求失败"})
                },
                success: function(res){
                    if(res.code == 0){
                        layer.alert(res.msg, {title: '保存成功'},function(index){
                            layer.closeAll(); //关闭所有弹层
                            layui.table.reload('tableReload', {page: {curr: 1}}); //调用业务弹层外表格重新加载
                        });
                    }
                }
            })
        });


    })
</script>